<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class error_with_option_name</title>
<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../program_options/reference.html#doxygen.errors_8hpp" title="Header &lt;boost/program_options/errors.hpp&gt;">
<link rel="prev" href="classboost_1_1program__options_1_1error__with__no__option__name.html" title="Class error_with_no_option_name">
<link rel="next" href="classboost_1_1program__options_1_1invalid__bool__value.html" title="Class invalid_bool_value">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
<td align="center"><a href="../../../index.html">Home</a></td>
<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="classboost_1_1program__options_1_1error__with__no__option__name.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../program_options/reference.html#doxygen.errors_8hpp"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="classboost_1_1program__options_1_1invalid__bool__value.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="doxygen.classboost_1_1program__options_1_1error__with__option__name"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class error_with_option_name</span></h2>
<p>boost::program_options::error_with_option_name</p>
</div>
<h2 class="refsynopsisdiv-title">Synopsis</h2>
<div class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../program_options/reference.html#doxygen.errors_8hpp" title="Header &lt;boost/program_options/errors.hpp&gt;">boost/program_options/errors.hpp</a>&gt;

</span>
<span class="keyword">class</span> <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html" title="Class error_with_option_name">error_with_option_name</a> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">program_options</span><span class="special">::</span><span class="identifier">error</span> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>

  <span class="comment">// <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#id-1_3_29_9_5_1_1_4_4-bb">public member functions</a></span>
  <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__name_1aea5c993b171132f39d6eea55f41b04ae"><span class="identifier">error_with_option_name</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> <span class="special">=</span> <span class="string">""</span><span class="special">,</span> 
                         <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> <span class="special">=</span> <span class="string">""</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__name_1ade18a0b6e05b7278ace554080ab2a744"><span class="identifier">set_substitute</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__name_1a8cc3df3b3f9936c44f1d406e51e53df5"><span class="identifier">set_substitute_default</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span><span class="special">,</span> 
                              <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__name_1abba11db6fe9519d13c5bb17c2c513542"><span class="identifier">add_context</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">int</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__name_1a63151fd51adb096a9106bf81c1a4c9d4"><span class="identifier">set_prefix</span></a><span class="special">(</span><span class="keyword">int</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__name_1aa8c47087e2c48b9a61c25d9bb0cd606e"><span class="identifier">set_option_name</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__name_1accbd5099d1b2596275b38d14d78f493a"><span class="identifier">get_option_name</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__name_1a18130a2ce6f2a3c592accccb69b2a5be"><span class="identifier">set_original_token</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__name_1afbd0b009684f5f382971010391f5361d"><span class="identifier">what</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#id-1_3_29_9_5_1_1_4_5-bb">protected member functions</a></span>
  <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__name_1a86fc238fbec89f22255f0ff34091076d"><span class="identifier">substitute_placeholders</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__name_1a7e4faaf6f707c513c3017f9dce4db10e"><span class="identifier">replace_token</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__name_1aef0ade94fc62c970a73ee0335a9c9322"><span class="identifier">get_canonical_option_name</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__name_1a0e175b9b7750003eb991201ad79f8199"><span class="identifier">get_canonical_option_prefix</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__namepublic-data-members">public data members</a></span>
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__name_1a8572dad0996f1668932553b5b151c850"><span class="identifier">m_error_template</span></a><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.29.9.6.6.4"></a><h2>Description</h2>
<p>Base class for most exceptions in the library.</p>
<p>Substitutes the values for the parameter name placeholders in the template to create the human readable error message</p>
<p>Placeholders are surrounded by % signs: example% Poor man's version of boost::format</p>
<p>If a parameter name is absent, perform default substitutions instead so ugly placeholders are never left in-place.</p>
<p>Options are displayed in "canonical" form This is the most unambiguous form of the <span class="emphasis"><em>parsed</em></span> option name and would correspond to <a class="link" href="classboost_1_1program__options_1_1option__description.html#doxygen.classboost_1_1program__options_1_1option__description_1adef6986ef64adfa9fc6ffb619a842fb3">option_description::format_name()</a> i.e. what is shown by print_usage()</p>
<p>The "canonical" form depends on whether the option is specified in short or long form, using dashes or slashes or without a prefix (from a configuration file) </p>
<div class="refsect2">
<a name="id-1.3.29.9.6.6.4.8"></a><h3>
<a name="id-1_3_29_9_5_1_1_4_4-bb"></a><code class="computeroutput">error_with_option_name</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem"><pre class="literallayout"><a name="doxygen.classboost_1_1program__options_1_1error__with__option__name_1aea5c993b171132f39d6eea55f41b04ae"></a><span class="identifier">error_with_option_name</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> template_<span class="special">,</span> 
                       <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> option_name <span class="special">=</span> <span class="string">""</span><span class="special">,</span> 
                       <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> original_token <span class="special">=</span> <span class="string">""</span><span class="special">,</span> 
                       <span class="keyword">int</span> option_style <span class="special">=</span> <span class="number">0</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="doxygen.classboost_1_1program__options_1_1error__with__option__name_1ade18a0b6e05b7278ace554080ab2a744"></a><span class="identifier">set_substitute</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> parameter_name<span class="special">,</span> 
                    <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> value<span class="special">)</span><span class="special">;</span></pre>
<p>gcc says that throw specification on dtor is loosened without this line <br>
 Substitute parameter_name-&gt;value to create the error message from the error template </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="doxygen.classboost_1_1program__options_1_1error__with__option__name_1a8cc3df3b3f9936c44f1d406e51e53df5"></a><span class="identifier">set_substitute_default</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> parameter_name<span class="special">,</span> 
                            <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> from<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> to<span class="special">)</span><span class="special">;</span></pre>
<p>If the parameter is missing, then make the from-&gt;to substitution instead </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="doxygen.classboost_1_1program__options_1_1error__with__option__name_1abba11db6fe9519d13c5bb17c2c513542"></a><span class="identifier">add_context</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> option_name<span class="special">,</span> 
                 <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> original_token<span class="special">,</span> <span class="keyword">int</span> option_style<span class="special">)</span><span class="special">;</span></pre>
<p>Add context to an exception </p>
</li>
<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="doxygen.classboost_1_1program__options_1_1error__with__option__name_1a63151fd51adb096a9106bf81c1a4c9d4"></a><span class="identifier">set_prefix</span><span class="special">(</span><span class="keyword">int</span> option_style<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="doxygen.classboost_1_1program__options_1_1error__with__option__name_1aa8c47087e2c48b9a61c25d9bb0cd606e"></a><span class="identifier">set_option_name</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> option_name<span class="special">)</span><span class="special">;</span></pre>
<p>Overridden in <a class="link" href="classboost_1_1program__options_1_1error__with__no__option__name.html" title="Class error_with_no_option_name">error_with_no_option_name</a> </p>
</li>
<li class="listitem"><pre class="literallayout"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a name="doxygen.classboost_1_1program__options_1_1error__with__option__name_1accbd5099d1b2596275b38d14d78f493a"></a><span class="identifier">get_option_name</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="doxygen.classboost_1_1program__options_1_1error__with__option__name_1a18130a2ce6f2a3c592accccb69b2a5be"></a><span class="identifier">set_original_token</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> original_token<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <a name="doxygen.classboost_1_1program__options_1_1error__with__option__name_1afbd0b009684f5f382971010391f5361d"></a><span class="identifier">what</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Creates the error_message on the fly Currently a thin wrapper for <a class="link" href="classboost_1_1program__options_1_1error__with__option__name.html#doxygen.classboost_1_1program__options_1_1error__with__option__name_1a86fc238fbec89f22255f0ff34091076d">substitute_placeholders()</a> </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.29.9.6.6.4.9"></a><h3>
<a name="id-1_3_29_9_5_1_1_4_5-bb"></a><code class="computeroutput">error_with_option_name</code> protected member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="doxygen.classboost_1_1program__options_1_1error__with__option__name_1a86fc238fbec89f22255f0ff34091076d"></a><span class="identifier">substitute_placeholders</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> error_template<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Makes all substitutions using the template </p>
</li>
<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="doxygen.classboost_1_1program__options_1_1error__with__option__name_1a7e4faaf6f707c513c3017f9dce4db10e"></a><span class="identifier">replace_token</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> from<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> to<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a name="doxygen.classboost_1_1program__options_1_1error__with__option__name_1aef0ade94fc62c970a73ee0335a9c9322"></a><span class="identifier">get_canonical_option_name</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Construct option name in accordance with the appropriate prefix style: i.e. long dash or short slash etc </p>
</li>
<li class="listitem"><pre class="literallayout"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a name="doxygen.classboost_1_1program__options_1_1error__with__option__name_1a0e175b9b7750003eb991201ad79f8199"></a><span class="identifier">get_canonical_option_prefix</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.29.9.6.6.4.10"></a><h3>
<a name="doxygen.classboost_1_1program__options_1_1error__with__option__namepublic-data-members"></a><code class="computeroutput">error_with_option_name</code> 
        public
       public data members</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a name="doxygen.classboost_1_1program__options_1_1error__with__option__name_1a8572dad0996f1668932553b5b151c850"></a><span class="identifier">m_error_template</span><span class="special">;</span></pre>
<p>template with placeholders </p>
</li></ol></div>
</div>
</div>
</div>
<div class="copyright-footer">Copyright © 2002-2004 Vladimir Prus<p>Distributed under the Boost Software License, Version 1.0.
      (See accompanying file <code class="filename">LICENSE_1_0.txt</code> or copy at 
      <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="classboost_1_1program__options_1_1error__with__no__option__name.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../program_options/reference.html#doxygen.errors_8hpp"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="classboost_1_1program__options_1_1invalid__bool__value.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
